home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / fbm12s.lha / tiff2fbm.c < prev    next >
C/C++ Source or Header  |  1994-07-18  |  3KB  |  97 lines

  1. /*****************************************************************
  2.  * tiff2fbm.c: FBM Release 1.0 25-Feb-90 Michael Mauldin
  3.  *
  4.  * Copyright (C) 1989,1990 by Michael Mauldin.  Permission is granted
  5.  * to use this file in whole or in part for any purpose, educational,
  6.  * recreational or commercial, provided that this copyright notice
  7.  * is retained unchanged.  This software is available to all free of
  8.  * charge by anonymous FTP and in the UUNET archives.
  9.  *
  10.  * tiff2fbm.c: 
  11.  *    Convert a TIFF format image to FBM format.  Uses Sam Leffler's
  12.  *    libtiff.a TIFF image library to read TIFF format.  See also,
  13.  *    fbm2tiff for the opposite conversion.
  14.  *
  15.  * USAGE
  16.  *    % tiff2fbm [ -<num> ] foo.tif > foo.fbm
  17.  *
  18.  * EDITLOG
  19.  *    LastEditDate = Mon Jun 25 00:18:45 1990 - Michael Mauldin
  20.  *    LastFileName = /usr2/mlm/src/misc/fbm/tiff2fbm.c
  21.  *
  22.  * HISTORY
  23.  * 25-Jun-90  Michael Mauldin (mlm@cs.cmu.edu) Carnegie Mellon
  24.  *    Package for Release 1.0
  25.  *
  26.  * 20-Jun-90  Paul Milazzo (milazzo) at BBN
  27.  *    Patched for STDC.
  28.  *
  29.  * 14-Jun-89  Michael Mauldin (mlm) at Carnegie-Mellon University
  30.  *    Created.  Based on tiff2ps by Sam Leffler.
  31.  *****************************************************************/
  32.  
  33. # include <stdio.h>
  34. # include <ctype.h>
  35. # include "fbm.h"
  36.  
  37. # define USAGE "Usage: tiff2fbm [ -<num> ] foo.tif > foo.fbm"
  38.  
  39. /****************************************************************
  40.  * main
  41.  ****************************************************************/
  42.  
  43. #ifndef lint
  44. static char *fbmid =
  45. "$FBM tiff2fbm.c <1.0> 25-Jun-90  (C) 1989,1990 by Michael Mauldin, source \
  46. code available free from MLM@CS.CMU.EDU and from UUNET archives$";
  47. #endif
  48.  
  49. main (argc, argv)
  50. char *argv[];
  51. { FBM image;
  52.   double aspect = 0.0;
  53.   char *fname = NULL, *title = NULL, *credits = NULL;
  54.   int outtype = FMT_FBM;
  55.  
  56.   /* Get the options */
  57.   while (--argc > 0 && (*++argv)[0] == '-')
  58.   { while (*++(*argv))
  59.     { switch (**argv)
  60.       {
  61.     case 'a':    aspect = atof (*argv+1); SKIPARG; break;
  62.     case 't':    title = *argv+1; SKIPARG; break;
  63.     case 'c':    credits = *argv+1; SKIPARG; break;
  64.     case 'A':    outtype = FMT_ATK; break;
  65.     case 'B':    outtype = FMT_FACE; break;
  66.     case 'F':    outtype = FMT_FBM; break;
  67.     case 'G':    outtype = FMT_GIF; break;
  68.     case 'I':    outtype = FMT_IFF; break;
  69.     case 'J':    outtype = FMT_JPEG; break;
  70.     case 'M':    outtype = FMT_MCP; break;
  71.     case 'P':    outtype = FMT_PBM; break;
  72.     case 'R':    outtype = FMT_RLE; break;
  73.     case 'S':    outtype = FMT_SUN; break;
  74.     case 'T':    outtype = FMT_TIFF; break;
  75.     case 'X':    outtype = FMT_X11; break;
  76.     case 'Z':    outtype = FMT_PCX; break;
  77.     default:        fprintf (stderr, "%s\n", USAGE);
  78.             exit (0);
  79.       }
  80.     }
  81.   }
  82.  
  83.   /* Get name of input file */
  84.   if (argc != 1)
  85.   { fprintf (stderr, "%s\n", USAGE);
  86.     exit (1);
  87.   }
  88.   
  89.   fname = *argv;
  90.  
  91.   if (read_tiff (&image, fname) &&
  92.       write_bitmap (&image, stdout, outtype))
  93.   { exit (0); }
  94.  
  95.   exit (1);
  96. }
  97.